/**
 * 路由设置文件
 */

var loaderCount = 1;
var loader = {};

var adminConfig = angular.module('admin.config', []);
var admin = angular.module('admin', [
    "ui.router",
    "ui.bootstrap",

    "ui.select",
    "ngSanitize",

    "LocalStorageModule",
    "ngAnimate",
    "ngResource",
    "textAngular",
    "admin.config",
]);
admin.config(function (localStorageServiceProvider) {
    localStorageServiceProvider
        .setPrefix('admin')
        //  .setStorageType('sessionStorage')
        .setNotify(true, true)
});
admin.config(function ($stateProvider, $urlRouterProvider) {
    //设置主页
    $urlRouterProvider.otherwise('/main');

    $stateProvider
        .state('login', {
            url: '/login',
            views: {
                "": {
                    templateUrl: 'view/login.html',
                    controller: 'LoginController'
                }
            }
        })
        // 设置视图
        .state('layout', {
            url: '/',
            views: {
                "": {
                    templateUrl: 'view/layout.html',
                    controller: 'InitController',
                },
                "header@layout": {
                    templateUrl: 'view/header.html',
                    controller: 'HeaderController'
                },
                "sidebar@layout": {
                    templateUrl: 'view/sidebar.html',
                    controller: 'SidebarController'
                },
                "footer@layout": {
                    templateUrl: 'view/footer.html',
                    controller: 'FooterController'
                }
            }
        })
        .state('layout.main', {
            url: 'main',
            views: {
                "main@layout": {templateUrl: 'view/main.html'}
            }
        })
        .state('layout.table', {
            url: 'table',
            views: {
                "main@layout": {
                    templateUrl: 'view/table.html',
                    controller : 'TableCtrl'
                }
            }
        })

// ------------------------------------------------------------------
// 列表
// ------------------------------------------------------------------
        .state('layout.list', {
            url: 'list',
            abstract:true
        })
        .state('layout.list.usr', {
            url: '/usr',
            views: {
                "main@layout": {
                    templateUrl: 'view/list/usr.html',
                    controller : 'UsrListCtrl'
                }
            }
        })
        .state('layout.list.dept', {
            url: '/dept',
            views: {
                "main@layout": {
                    templateUrl: 'view/list/dept.html',
                    controller : 'DeptListCtrl'
                }
            }
        })
        .state('layout.list.classes', {
            url: '/classes',
            views: {
                "main@layout": {
                    templateUrl: 'view/list/classes.html',
                    controller : 'ClassesListCtrl'
                }
            }
        })
        .state('layout.list.role', {
            url: '/role',
            views: {
                "main@layout": {
                    templateUrl: 'view/list/role.html',
                    controller : 'RoleListCtrl'
                }
            }
        })
        .state('layout.list.term', {
            url: '/term',
            views: {
                "main@layout": {
                    templateUrl: 'view/list/term.html',
                    controller : 'TermListCtrl'
                }
            }
        })
        .state('layout.list.att_item', {
            url: '/att_item',
            views: {
                "main@layout": {
                    templateUrl: 'view/list/att_item.html',
                    controller : 'AttItemListCtrl'
                }
            }
        })
        // --------------------------------------------------------
        // 日常管理
        // --------------------------------------------------------
        .state('layout.list.att_form', {
            url: '/att_form',
            views: {
                "main@layout": {
                    templateUrl: 'view/list/att_form.html',
                    controller : 'AttFormListCtrl'
                }
            }
        })
        .state('layout.list.activity', {
            url: '/activity',
            views: {
                "main@layout": {
                    templateUrl: 'view/list/activity.html',
                    controller : 'ActivityListCtrl'
                }
            }
        })
        .state('layout.list.task', {
            url: '/task',
            views: {
                "main@layout": {
                    templateUrl: 'view/list/task.html',
                    controller : 'TaskListCtrl'
                }
            }
        })

// -----------------------------------------------------------------
// 详细内容
// -----------------------------------------------------------------
        .state('layout.detail', {
            url: 'detail',
            abstract:true
        })
        .state('layout.detail.usr', {
            url: '/usr/:id',
            views: {
                "main@layout": {
                    templateUrl: 'view/detail/usr.html',
                    controller : 'UsrDetailCtrl'
                }
            }
        })
        .state('layout.detail.dept', {
            url: '/dept/:id',
            views: {
                "main@layout": {
                    templateUrl: 'view/detail/dept.html',
                    controller : 'DeptDetailCtrl'
                }
            }
        })
        .state('layout.detail.classes', {
            url: '/classes/:id',
            views: {
                "main@layout": {
                    templateUrl: 'view/detail/classes.html',
                    controller : 'ClassesDetailCtrl'
                }
            }
        })
        .state('layout.detail.role', {
            url: '/role/:id',
            views: {
                "main@layout": {
                    templateUrl: 'view/detail/role.html',
                    controller : 'RoleDetailCtrl'
                }
            }
        })
        .state('layout.detail.term', {
            url: '/term/:id',
            views: {
                "main@layout": {
                    templateUrl: 'view/detail/term.html',
                    controller : 'TermDetailCtrl'
                }
            }
        })
        .state('layout.detail.att_item', {
            url: '/att_item/:id',
            views: {
                "main@layout": {
                    templateUrl: 'view/detail/att_item.html',
                    controller : 'AttItemDetailCtrl'
                }
            }
        })
// -----------------------------------------------------------------
// 添加页面
// -----------------------------------------------------------------
        .state('layout.add', {
            url: 'add',
            abstract:true
        })
        .state('layout.add.dept', {
            url: '/dept',
            views:{
                "main@layout":{
                    templateUrl: 'view/add/dept.html',
                    controller : 'DeptAddCtrl'
                }
            }
        })
        .state('layout.add.classes', {
            url: '/classes',
            views:{
                "main@layout":{
                    templateUrl: 'view/add/classes.html',
                    controller : 'ClassesAddCtrl'
                }
            }
        })
        .state('layout.add.role', {
            url: '/role',
            views:{
                "main@layout":{
                    templateUrl: 'view/add/role.html',
                    controller : 'RoleAddCtrl'
                }
            }
        })
        .state('layout.add.term', {
            url: '/term',
            views:{
                "main@layout":{
                    templateUrl: 'view/add/term.html',
                    controller : 'TermAddCtrl'
                }
            }
        })
        .state('layout.add.att_item', {
            url: '/att_item',
            views:{
                "main@layout":{
                    templateUrl: 'view/add/att_item.html',
                    controller : 'AttItemAddCtrl'
                }
            }
        })
});
